﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JtextEpicsInterface
{
    //describe many things about the property that contains in the message 
    /// <summary>
    /// describe many things about the property that contains in the message 
    /// <para>with this the EJServer can rip a value out from a message,and put into co-respoding PV</para>
    /// <pare>the member tagged with in xml means it can be retrieved from SDD XML</pare>
    /// </summary>
    public class MessageProp
    {
        /// <summary>
        /// if the server is byte cmd ;in XML
        /// </summary>
        public bool isByte;    //if the server is byte cmd ;in XML


        /// <summary>
        /// The pvName,;in XML
        /// </summary>
        public string pvName;       //;in XML


        /// <summary>
        /// in which postion should i get the value and put into pv  ;in XML
        /// <para>for byte message it indicate the start byte of this value</para>
        /// <para>for string message it indicate the sub string in the message that split by the spliter</para>
        /// </summary>
        public int Position;   //the position in a cmd  ;in XML
        /// <summary>
        /// only used in byte cmd  ;in XML
        /// the value is on position + offset
        /// </summary>
        public int offset; //only used in byte cmd  ;in XML
        /// <summary>
        /// the value
        /// </summary>
        public object VAL;
        /// <summary>
        /// if there more then one byte that consist this value,how many byte should be used to make up a value ..
        ///  neg NO is from hi to lo, pos NO is lo to hi ,1 to 8(double is 8byte);
        ///in XML
        /// </summary>
        public int shift;   //how many byte should be shift in to one double neg NO is from hi to lo, pos NO is lo to hi ,1 to 8(double is 8byte)
        //comment below is no longer used   ;in XML
        //ONLY USED IN BYTE, TO COMBINE MULTI BYTE TO one double ,you can shit this byte to any postions from right(low) to left 0-63

        /// <summary>
        /// //do you have to rip a bit out of a a byte which bit? ;in XML
        /// </summary>
        public short isBit;   //do you have to rip a bit out of a a byte  ;in XML
        // public Type myType;


        

        /// <summary>
        /// Initializes a new instance of the <see cref="MessageProp"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="pos">The pos.</param>
        /// <param name="off">The off.</param>
        /// <param name="isbyte">if set to <c>true</c> [isbyte].</param>
        /// <param name="isbit">The isbit.</param>
        /// <param name="thisshift">The thisshift.</param>
        public MessageProp(string name, int pos, int off, bool isbyte, short isbit, int thisshift)
        {
            isByte = isbyte;
            pvName = name;
            Position = pos;
            offset = off;
            isBit = isbit;
            //myType = type;
            shift = thisshift;
        }



        #region Device
        /// <summary>
        /// for device use
        /// </summary>
        public string DeviceName;   //in which Device;in XML
        public string DeviceProperty;   //one device property is co-respond to a pvName in=="NULL" then this record is not a DeviceProperty in XML
        public string DeviceDtatType;   //the dataType of this  device Property ，//in this string ,we use a patern like: DataType;Direction.；in XML

        #endregion

        public MessageProp()
        {

        }



    }
}
